import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Sysconstant } from '../sysconstant.enum';


@Component({
  selector: 'app-book',
  templateUrl: './book.component.html',
  styleUrls: ['./book.component.css']
})
export class BookComponent implements OnInit {
  public books: any;
  book: any;
  isReader = false;
  constructor(private httpClient: HttpClient) { }

  ngOnInit() {
    this.initIndex();
    // this.readMore('1222');
  }
  initIndex() {
    this.httpClient.get(Sysconstant.BASE_URL + "/book/index").subscribe(data => {
      this.books = data;
    }, err => {
      console.log("error");
    })
  }

 public readMore(id: string) {
    this.httpClient.get(Sysconstant.BASE_URL + "/book/" + id).subscribe(data => {
      this.book = data;
      this.isReader = true;
    }, err => {
      console.log("error");
    })
  }
  back() {
    this.isReader = false;
  }

}
